from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Patient(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    patient_id = models.CharField(max_length=18,primary_key=True,default=' ')
    contact_no = models.CharField(max_length=11)
    address = models.CharField(max_length=200)
    sex = models.CharField(max_length=4,default="无")
    dob = models.DateField()
    blood_group = models.CharField(max_length=3)

    def __str__(self):
        return self.user.username


class Department(models.Model):
    department_name = models.CharField(max_length=64,default=' ')

    def __str__(self):
        return self.department_name


class Doctor(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    contact_no = models.CharField(max_length=11)
    sex = models.CharField(max_length=4,default='无')
    doctor_description = models.CharField(max_length=256,null=True)
    department = models.ForeignKey(Department, on_delete=models.CASCADE, default=0)

    def __str__(self):
        return self.user.username


class Receptionist(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)

    def __str__(self):
        return self.user.username


class Lab_Doctor(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    lab_department = models.ForeignKey(Department, on_delete=models.CASCADE)

    def __str__(self):
        return self.user.username


class Inventory_manager(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)

    def __str__(self):
        return self.user.username
